﻿using Supermarket;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace XLSupermarket.Admin.Ad_update
{
    public partial class Ad_update : Form
    {
        public Ad_update()
        {
            InitializeComponent();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Ad_update_Load(object sender, EventArgs e)
        {
            //把Ad_zscg界面定义的ID接收过来
            string id = Ad_zscg.Ad_zscg.ID;
            string sql = string.Format("select*from VIP_information where VIP_ID='{0}'", id);
            DataTable dt = DBHelper.FillData(sql);
            textBox4.Text = dt.Rows[0]["VIP_Name"].ToString();
            dateTimePicker1.Value= DateTime.Parse(dt.Rows[0]["VIP_time"].ToString());
            textBox5.Text = dt.Rows[0]["VIP_TEL"].ToString();
            textBox3.Text = dt.Rows[0]["VIP_Score"].ToString();
            textBox6.Text = dt.Rows[0]["Other"].ToString();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string VIP_Name = this.textBox4.Text;
            string VIP_time = this.dateTimePicker1.Value.ToString("yyyy-MM-dd");
            string VIP_TEL = this.textBox5.Text;
            string VIP_Score = this.textBox3.Text;
            string Other = this.textBox6.Text;
            //把Ad_zscg界面定义的ID接收过来
            string id = Ad_zscg.Ad_zscg.ID;
            //修改语句
            string sql = string.Format
                ("update VIP_information set VIP_Name='{0}',VIP_time='{1}',VIP_TEL='{2}',VIP_Score='{3}',Other='{4}' where VIP_ID='{5}'",
                VIP_Name, VIP_time, VIP_TEL, VIP_Score, Other, id);
            int tj = DBHelper.Edit(sql);
            if (tj > 0)
            {
                MessageBox.Show("修改成功");

            }
            else
            {
                MessageBox.Show("修改失败");
            }

        }
    }
}
